﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using Panny.Data;
using System.Data.SqlClient;
using DBUtility;//请先添加引用
namespace Easydp.Models
{
   public class NewsManager
    {
       public DataSet GetDataset(int areaId,int categoryId)
       {
           using (SqlStoredProcedure selection = new SqlStoredProcedure("Pro_Pan_TT_News_Select"))
           {
               if(areaId > 0 )
                    selection.AddParameter("@AreaID",areaId);
               else
                   selection.AddParameter("@AreaID", DBNull.Value);
               if(categoryId>0)
                   selection.AddParameter("@CategoryID", categoryId);
               else
                    selection.AddParameter("@CategoryID", DBNull.Value);
               return selection.GetDataset();
           }
       }

       public DataSet GetDataset(int newsID)
       {
           using (SqlStoredProcedure selection = new SqlStoredProcedure("Pro_Pan_TT_News_SelectSingle"))
           {
               selection.AddParameter("@NewsID", newsID);
               return selection.GetDataset();
           }
       }
       public DataSet GetDataset(string sql)
       {
           //StringBuilder sql = new StringBuilder();
           //sql.Append(" select * from v_TT_News_Pan_Select ");
           //if (!string.IsNullOrEmpty(sqlWhere))
           //    sql.AppendFormat(" where {0}", sqlWhere);
           using (SqlText selection = new SqlText(sql.ToString()))
           {
               return selection.GetDataset();
           }
       }
    }
     
}
